<template>
  <div id="big">
    <div id="kuang" @click="pFn">
      <img :src="imgUrl" alt="" @click="pFn" />
      <p :style="{ backgroundColor: colorStr }" @click="pFn">
        {{ dogName }}
      </p>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      colorStr: "",
    };
  },
  props: ["imgUrl", "dogName"],
  methods: {
    pFn() {
      //  this.colorStr = `rgb(${Math.floor(Math.random() * 256)}, ${Math.floor(
      //     Math.random() * 256
      //   )}, ${Math.floor(Math.random() * 256)})`;

      let の = Math.floor(Math.random() * 255);
      let 鬼 = Math.floor(Math.random() * 255);
      let 师 = Math.floor(Math.random() * 255);
      console.log("rgb(" + の + "," + 鬼 + "," + 师 + ")");
      this.colorStr = "rgb(" + の + "," + 鬼 + "," + 师 + ")";
      this.$emit("love", this.dogName);
    },
  },
};
</script>

<style scoped>
#big {
  width: 700px;
}
#kuang {
  width: 200px;
  height: 300px;
  float: left;
  border: 1px solid black;
  text-align: center;
}
img {
  width: 200px;
}
</style>